<script type="text/javascript" src="<?php echo $url_template?>/js/holder.js"></script>

<h2>Annonces <a class="btn" href="<?php echo $CFG->config['base_url']?>product/admin/new_product">Ajouter</a></h2>


<form class="form-horizontal" method="post" action="" id="posts-filter">

<div class="navbar">
<div class="navbar-inner">
		<ul class="nav">
			<li><a class="current" href="<?php echo $CFG->config['base_url']?>product/admin">Tous <span class="count">(<?php echo $total?>)</span></a></li>
			<li class="divider-vertical"></li>
			<li><a href="<?php echo $CFG->config['base_url']?>product/admin/index/status/publish">Activé <span class="count">(<?php echo $totalActive?>)</span></a></li>
		</ul>
		<ul class=" navbar-form  pull-right">
        <div class="input-append">
            <input type="text"  name="s"/>
            <button type="submit" class="btn"><i class="icon-search"></i></button>
        </div>
        </ul>
</div>
</div>

<div class="navbar">
  <div class="navbar-form">
    <div class="container">
      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </a>
      
      <div class="nav-collapse collapse">
        <ul class="nav">
          <li>
	          <select name="action">
					<option selected="selected" value="">Actions Groupées</option>
					<option class="hide-if-no-js" value="edit">Modifier</option>
					<option value="trash">Déplacer dans la Corbeille</option>
				</select>
			</li>
            <li>
	            <select name="filter[date]">
					<option value="" selected="selected">Toutes Dates</option>
					<?php 
					foreach($option_filter_date as $list){
						$s=$list->YearMonth==$filter['date']?' selected ' : '';
						echo "<option value='{$list->YearMonth}' $s>{$list->month} - {$list->year}</option>";
					}
					?>
				</select>
          </li>                    
          <li>
            <select class="postform" id="cat" name="filter[category]" onchange="if(this.value=!'')showOption(this.value)" >
				<option value="" >Categorie</option>
					<?php echo $option_filter_category?>
			</select>
			<input type="submit" value="Filtrer" class="btn" id="post-query-submit">
          	<input type="hidden" size="1" value="<?php echo $paged?>" name="paged" title="Page actuelle" id="current-page" class="current-page">
          </li>
        </ul>
        <ul class="nav pull-right">
        	<li><?php echo $totalActive?> annonces </li>
        	<li> &nbsp </li>
        	<li class="pagination pagination-small">
				<ul>
					<li><a href="#" onclick="$('#current-page').val(parseInt($('#current-page').val())-<?php echo $limit?>)">Prev</a></li>
					<?php foreach (range(1, ceil($total/$limit)) as $numPage):?>
					<li <?php if($paged==$numPage*$limit)echo 'class="disabled "' ?>><a href="#"  onclick="$('#current-page').val(<?php echo $numPage*$limit?>)" ><?php echo $numPage?></a></li>
					<?php endforeach;?>
					
					 <li><a href="#" onclick="$('#current-page').val(parseInt($('#current-page').val())+<?php echo $limit?>)">Next</a></li>
				</ul>
        	</li>
        </ul> 
        <script type="text/javascript">

        $(".pagination a").click(function () {
        		$('#posts-filter').submit();
        });
        </script>
        
      </div><!-- /.nav-collapse -->
    </div>
  </div><!-- /navbar-inner -->
</div>

	<div id="pagePostOption">
		<div id="showOption">
		<?php echo $category_option?>
		</div>
	</div>
		
<script type="text/javascript">
	function showOption($value){
		$.post("<?php echo $CFG->config['base_url']?>setting/option/getFilters", {idOption:$value } ).
		done(function($data) {
		$('#pagePostOption').show('slow');
		$('#showOption').html($data);
		});
	} 
	function sort($nameCol,$this){
		$input=$this.next("input");
		$typeOfSort=$input.val();
		
		if($typeOfSort=='desc')$typeOfSort='asc';
		else $typeOfSort='desc';
		$input.attr('name','sort['+$nameCol+']');
		$input.val($typeOfSort);
		$('#posts-filter').submit();
	}
</script>
		
<table class="table">
	<thead>
	<tr>
		<th  id="annoncetout" scope="col">
			<input type="checkbox" id="cb-select-all-1" class="checkall"/>
		</th>
		<th>Photos</th>
		<th  class="sortable <?php echo $sort['prd_name']?>">
			<a href="#" onclick="sort('prd_name',$(this))"><span>Titre & Texte</span><span class="sorting-indicator"></span></a>
			<input type="hidden" value="<?php echo $sort['prd_name']?>" name="sort[prd_name]" />
		</th>
		<th>Categories</th>
		<th>Information</th>
		<th>Prix</th>
		<th>V</th>
        <th>Date Créa</th>
        <th>Dep.</th>
        <th class="<?php echo $sort['prd_counter']?>">
			
			<a href="#" onclick="sort('prd_counter',$(this))">
				<span>Vues</span>
				<span class="sorting-indicator"></span>
			</a>
			<input type="hidden" value="<?php echo $sort['prd_counter']?>" name="sort[prd_counter]" />
		</th>
		<th>Pro</span><span class="sorting-indicator"></span></a></th>
        <th>Montant</span><span class="sorting-indicator"></span></a></th>
       </tr>
	</thead>

	<tfoot>
	<tr>
		<th id="annoncetout" scope="col">
		<input type="checkbox" id="cb-select-all-1"  class="checkall"/>
		</th>
		<th>Photos</th>
		<th  class="<?php echo $sort['prd_name']?>" scope="col">
			<a href="#" onclick="sort('prd_name',$(this))"><span>Titre & Texte</span><span class="sorting-indicator"></span></a>
			<input type="hidden" value="<?php echo $sort['prd_name']?>" name="sort[prd_name]" />
		</th>
		<th>Categories</th>
		<th>Information</th>
		<th>Prix</th>
		<th>V</th>
        <th>Date Créa</th>
        <th>Dep.</th>
        <th class="<?php echo $sort['prd_counter']?>" scope="col">
			
			<a href="#" onclick="sort('prd_counter',$(this))">
				<span>Vues</span>
				<span class="sorting-indicator"></span>
			</a>
			<input type="hidden" value="<?php echo $sort['prd_counter']?>" name="sort[prd_counter]" />
		</th>
		<th>Pro</span><span class="sorting-indicator"></span></a></th>
        <th>Montant</span><span class="sorting-indicator"></span></a></th>
	</tr>
	</tfoot>

	<tbody id="the-list">
	<?php 
	if(!empty($listAllProducts))
		foreach ($listAllProducts as $product){

	?>
		<tr valign="top" id="post-<?php echo $product->prd_id?>">
			<th>
				
				<input type="checkbox" value="<?php echo $product->prd_id?>" name="post[]" id="cb-select-<?php echo $product->prd_id?>">
			</th>
			<td class="span1"> <img style="height: 100px" data-src="holder.js/160x120" src="<?php echo $CFG->config['base_url']?>images/thumbnails/<?php echo $product->link_photo?>"/> </td>
			<td class="show-action">
				<strong>
				<a title="Modifier <?php echo $product->prd_name?>" href="<?php echo $CFG->config['base_url']?>product/admin/edit/<?php echo $product->prd_id?>" class="row-title"><?php echo $product->prd_name?></a><br />
				</strong>
				<div id="lignes" class="lignes">
                	<?php echo substr_replace(strip_tags($product->prd_description),'',55,-1)?>...
                </div>
				<div class="row-actions">
					<span class="edit"><a title="Modifier Produit" href="<?php echo $CFG->config['base_url']?>product/admin/edit/<?php echo $product->prd_id?>">Modifier</a> | </span>
					<?php $activeProduct=$product->prd_active?'deactive':'reactive';
					$activeProductShow=$product->prd_active?'Déactiver':'reactiver';
					?>
					<span class="trash"><a href="<?php echo $CFG->config['base_url']?>product/admin/<?php echo $activeProduct.'/'.$product->prd_id?>" title="placer dans le corbeille" class="submitdelete"><?php echo $activeProductShow?></a> | </span>
					<span class="view"><a rel="permalink" title="Voir <?php echo $product->prd_name?>" href="<?php echo $CFG->config['base_url'].$product->link_cat_product."/".$product->prd_link.".html"?>">Apperçu</a></span>
				</div>
			</td>
			<td>
				<div class="categorie"><?php echo $product->category_name?></div>
          	</td>
			<td>
				<div id="nom" class="nom">
					<strong title="Nom et Prénom"> <?php echo $product->user_name?></strong>
				</div>
				<div id="telephone" class="telephone">
					<strong title="Téléphone" class="<?php echo $product->user_tel_show?'strike':''?>"> <?php echo $product->user_tel?></strong>
				</div>
				<div id="email" class="email">
					<strong title="email"> <?php echo $product->user_email?></strong>
				</div>                
            </td>
			<td>
            	<div id="texteprix" class="texteprix"><?php echo $product->prd_price?><?php echo $CFG->config['admin_currency']?></div>
          	</td>
		  	<td class="column-annoncevaliderpng">
		  		<?php echo $product->prd_active?
					' <div class="valideroui"> </div>':
		  			' <div class="validernon"> </div>'.
		  			'<a tilte="Envoyer un Email de confirmation" href="'.$CFG->config['base_url'].'product/admin/send/'. $product->prd_id.'">Ok</a>'
		  		;?>
		  		
            </td>
			<td>
	            <div title="creation" class="creation"><?php echo date($CFG->config['date_format'],$product->date_create)?></div>
	            <div title="expiration" class="expiration"><?php echo date($CFG->config['date_format'],$product->date_validate)?></div>
	            <div title="date fin de priorité" class="priority"><?php echo $product->priority_date ? date($CFG->config['date_format'],$product->priority_date):''?></div>
	            <br/>
	        </td>
			<td>
	             <div id="cp" class="cp" title="<?php echo $product->ville?>"><?php echo $product->prd_codepostal?></div>
	        </td>
            <td><?php echo $product->prd_counter?></td>
			<td>
			<?php echo ($product->shop_id)? "<a href='{$CFG->config['base_url']}shop/admin/edit/$product->shop_id'>Pro</a>":""?>
	            <?php echo $product->company?
					' <div class="iconparticulier"> </div>':
		  			' <div class="iconprofessionnel"> </div>';?>
            </td>
          <td><?php echo $product->prd_paid?></td>
		</tr>
		<?php }?>
	</tbody>
</table>
<div class="pagination pagination-small">

        <ul class="nav pull-right">
        	<li><?php echo $totalActive?> annonces </li>
        	<li> &nbsp </li>
        	<li class="pagination pagination-small">
				<ul>
					<li><a href="#" onclick="$('#current-page').val(parseInt($('#current-page').val())-<?php echo $limit?>)">Prev</a></li>
					<?php foreach (range(1, ceil($total/$limit)) as $numPage):?>
					<li <?php if($paged==$numPage*$limit)echo 'class="disabled "' ?>><a href="#"  onclick="$('#current-page').val(<?php echo $numPage*$limit?>)" ><?php echo $numPage?></a></li>
					<?php endforeach;?>
					
					 <li><a href="#" onclick="$('#current-page').val(parseInt($('#current-page').val())+<?php echo $limit?>)">Next</a></li>
				</ul>
        	</li>
        </ul> 
</div>
</form>


<div id="ajax-response"></div>
<br class="clear"/>
</div>



<div class="clear"></div>